<link rel="stylesheet" href="/css/map/detailgrid.css">
<?php $flgFirst=true ?>
<?php $flgLast=true ?>
<?php if (count($griddetail)>0): ?>

<table class="grid" cellpadding="0" cellspacing="0" style="width: 100%;">
        <tr  style="background-color: #e6e6d2">
        <th class="exp">

        </th>
        <th class="location">
            Location
        </th>
        <th class="depth">
            Depth
        </th>
        <th class="quantity">
            Quantity
        </th>
        <th class="observationdate">
            Observation Date
        </th>
        <th class="observationtime">
            Observation Time
        </th>
        <th class="tag">
            Tag
        </th>
    </tr>
<tbody style="overflow-x: hidden; overflow-y: auto; height: 430px;" id="gridtbody">
<?php $flgCategory =""?>
    <?php foreach($griddetail as $r): ?>
<?php if ($flgCategory!=$r->Species["species"]): ?>
    <tr>
        <td colspan="7" class="category" style="height: 40px">

            <img style="border:none; padding:0px; margin:  0px; margin-right: 5px" src="/images/fish.png" width="16px;" height="16px"/>
            <?php echo $r->Species["species"] ?>
            <?php $flgCategory= $r->Species["species"] ?>

        </td>
    </tr>
<?php endif ?>
    <tr onclick="showattributerow('hdrow<?php echo $r["speciesid"].$r->Observationdepth["id"] ?>',<?php echo $r->Observationdepth["id"] ?>,'BIO')">
        <td class="exp">
            <a class="expand" id="hdrow<?php echo $r["speciesid"].$r->Observationdepth["id"] ?>_a" ></a>
        </td>
        <td class="location">
            <?php echo $r->Observationdepth->Observation["location"] ?>
        </td>
        <td class="depth">
            <?php echo $r->Observationdepth["observationdepth"]." ".$r->Observationdepth->Unit["unit"] ?>
        </td>
        <td class="quantity">
            <?php echo $r["quantity"] ?>
        </td>
        <td class="observationdate">
            <?php echo $r->Observationdepth->Observation["observationdate"] ?>
        </td>
        <td class="observationtime">
            <?php echo $r->Observationdepth->Observation["observationtime"] ?>
        </td>
        <td class="tag">
            <?php echo $r["tag"] ?>
        </td>
     </tr>
     <tr class="attributerow"  id="hdrow<?php echo $r["speciesid"].$r->Observationdepth["id"] ?>">
         <td  colspan="7" id ="tdhdrow<?php echo $r["speciesid"].$r->Observationdepth["id"] ?>" align="left">
             
         </td>
     </tr>
<?php endforeach ?>
    
</tbody>
</table>

                    <?php if ($griddetail->haveToPaginate()): ?>
                    <div style="background-color: #e6e6d2; width: 100%; height: 25px; padding-left: 2px; padding-top: 2px; padding-bottom: 2px">
                    <?php $links = $griddetail->getLinks(); foreach ($links as $page): ?>
                        <?php if ($page==$griddetail->getFirstpage()): $flgFirst=false; endif ?>
                        <?php if ($page==$griddetail->getLastpage()): $flgLast=false; endif ?>
                    <?php endforeach ?>
                    <?php if ($griddetail->getPage()!=$griddetail->getFirstpage()):?>
                        <div class="pagination">
                            <a class="pgnumber" onclick="loadgridpage(<?php echo $griddetail->getPreviousPage() ?>,'BIO')">Previous</a>
                        </div>
                    <?php endif ?>
                    <?php if ($flgFirst==true):?>
                        <div class="pagination">
                            <a class="pgnumber" onclick="loadgridpage(<?php echo $griddetail->getFirstPage()?>,'BIO')"><?php echo$griddetail->getFirstPage()?></a>
                        </div>
                        <div class="pagination">
                            ..
                        </div>
                    <?php endif ?>


                    <?php $links = $griddetail->getLinks(); foreach ($links as $page): ?>
                        <div class="pagination">
                            <?php //echo ($page == $griddetail->getPage())// ? $page : link_to($page, 'bussiness/index?page='.$page) ?>
                            <?php if ($griddetail->getPage()==$page): ?>
                            <a class="pgnumberactive" onclick="loadgridpage(<?php echo $page?>,'BIO')"><?php echo $page?></a>
                            <?php else:?>
                            <a class="pgnumber" onclick="loadgridpage(<?php echo $page?>,'BIO')"><?php echo $page?></a>
                            <?php endif ?>
                        </div>
                    <?php endforeach ?>
                    <?php if ($page!=$griddetail->getLastpage() && $flgLast!=false):?>
                        <div class="pagination">
                            ..
                        </div>
                        <div class="pagination">
                            <a class="pgnumber" onclick="loadgridpage(<?php echo $griddetail->getLastPage()?>,'BIO')"><?php echo$griddetail->getLastPage()?></a>
                        </div>
                    <?php endif ?>
                    <?php if ($griddetail->getPage()!=$griddetail->getLastpage()):?>
                        <div class="pagination">
                            <a class="pgnumber"  onclick="loadgridpage(<?php echo $griddetail->getNextPage() ?>,'BIO')">Next</a>
                        </div>
                    <?php endif ?>
                        </div>
            <?php endif?>





<?php else:echo "No data found"; endif ?>